/*
package com.shiku.payment.controller;

import com.alibaba.fastjson.JSONObject;
import com.shiku.im.api.service.AuthServiceUtils;
import com.shiku.im.api.service.base.AbstractController;
import com.shiku.im.comm.constants.KConstants;
import com.shiku.im.comm.utils.ReqUtil;
import com.shiku.im.pay.constants.PayResultCode;
import com.shiku.im.user.service.AuthKeysService;
import com.shiku.im.vo.JSONMessage;
import com.shiku.payment.constant.PayConstant;
import com.shiku.payment.dto.PayRequestDTO;
import com.shiku.payment.dto.PaymentOrderDTO;
import com.shiku.payment.dto.SubmitOrderDTO;
import com.shiku.payment.service.PaymentLogicService;
import com.shiku.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@Api(value="PaymentController",tags="对接支付平台相关接口")
@RequestMapping(value="/payment",method={RequestMethod.GET,RequestMethod.POST})
@RestController
public class PaymentController extends AbstractController {


    @Autowired
    private AuthKeysService authKeysService;


    @Autowired
    private AuthServiceUtils authServiceUtils;


    @Autowired
    private PaymentLogicService paymentLogicService;




    @ApiOperation("提交生成支付订单接口")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/submitOrder")
    public JSONMessage submitOrder(HttpServletRequest request, @ModelAttribute @Valid SubmitOrderDTO orderDTO){
        Integer userId= ReqUtil.getUserId();
        //String token=getAccess_token();
        if(null==orderDTO) {
            return JSONMessage.failureByErrCode(KConstants.ResultCode.AUTH_FAILED);
        }

        try {
            orderDTO.setClientIp(request.getRemoteAddr());
            JSONObject jsonObject = paymentLogicService.submitOrder(userId,orderDTO);
            return JSONMessage.success(jsonObject);
        } catch (Exception e) {
            return JSONMessage.failureByException(e);
        }

    }


    @ApiOperation("请求支付订单选择支付方式")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "payOrderId",value = "订单支付令牌",dataType = "String",required = true,defaultValue = ""),
    })
    @RequestMapping(value = "/selectPayChannelRequest")
    public JSONMessage selectPayChannelRequest(@RequestParam(defaultValue="") String payOrderId){
        Integer userId= ReqUtil.getUserId();
        //String token=getAccess_token();

        try {
           return JSONMessage.success(paymentLogicService.selectPayChannelRequest(payOrderId));

        } catch (Exception e) {
            return JSONMessage.failureByException(e);
        }

    }

    @ApiOperation("根据支付方式发起支付请求")
    @RequestMapping(value = "/doPayRequest")
    public JSONMessage doPayRequest(@Valid PayRequestDTO payRequestDTO){
        Integer userId= ReqUtil.getUserId();
        //String token=getAccess_token();
        try {
            JSONObject jsonObject = paymentLogicService.doPayRequestBefore(userId, payRequestDTO);

            return JSONMessage.success(jsonObject);
        } catch (Exception e) {
            return JSONMessage.failureByException(e);
        }

    }

    @ApiOperation("余额输入密码支付订单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "codeId",value = "支付ID",dataType = "String",required = true,defaultValue = ""),
            @ApiImplicitParam(paramType = "query",name = "data",value = "加密参数",dataType = "String",required = true,defaultValue = "")
    })
    @RequestMapping(value = "/payOrderByPassWord")
    public JSONMessage payOrderByPassWord(@RequestParam(defaultValue="") String codeId, @RequestParam(defaultValue="") String data){
        Integer userId= ReqUtil.getUserId();
        String token=getAccess_token();

        byte[] decode =authServiceUtils.getPayCodeById(userId, codeId);
        if(null==decode) {
            return JSONMessage.failureByErrCode(KConstants.ResultCode.ParamsAuthFail);
        }
        JSONObject jsonObj = authServiceUtils.decodePayDataJson( data, decode);
        if(null==jsonObj) {
            return JSONMessage.failureByErrCode(KConstants.ResultCode.ParamsAuthFail);
        }

        String payPassword = authKeysService.getPayPassword(userId);

        String payOrderId = jsonObj.getString("payOrderId");

        if(StringUtil.isEmpty(payOrderId)){
            return JSONMessage.failureByErrCode(KConstants.ResultCode.ParamsAuthFail);
        }
        */
/**
         * 查询订单签名
         *//*

        PaymentOrderDTO orderDTO = paymentLogicService.queryPayOrder(payOrderId);

        jsonObj.put("sign",payOrderId+orderDTO.getSign());

        // 校验加密规则
         jsonObj = authServiceUtils.authPaymentOrderPay(userId, token, jsonObj,  decode,payPassword);
        if(null==jsonObj) {
            return JSONMessage.failureByErrCode(PayResultCode.PayPasswordIsWrong);
        }
        PayRequestDTO payRequestDTO = new PayRequestDTO();
        payRequestDTO.setPayOrderId(payOrderId);
        payRequestDTO.setChannelId(PayConstant.PAY_CHANNEL_BALANCE);
        try {
            if(null==payRequestDTO){
                return JSONMessage.failureByErrCode(KConstants.ResultCode.ParamsAuthFail);
            }
            JSONObject jsonObject = paymentLogicService.payOrderByPassWord(userId, payRequestDTO);
            if(null==jsonObject){
                return JSONMessage.failure("");
            }
            return JSONMessage.success();

        } catch (Exception e) {
            return JSONMessage.failureByException(e);
        }

    }


}
*/
